#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double db;
inline LL read()
{
	LL x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
const int MAXN=1510,INF=0x3f3f3f3f;
LL n,head[MAXN],cnt,val[MAXN],f[MAXN][3];
struct edge
{
	LL v,next;
}e[MAXN*2];
void addedge(LL x,LL y)
{
	e[++cnt]=(edge){y,head[x]};
	head[x]=cnt;
	return;
}
void treedp(LL u,LL fa)
{
	f[u][2]=val[u];
	LL _min=INF;
	bool k=false;
	for(LL i=head[u];i;i=e[i].next)
	{
		LL v=e[i].v;
		if(v==fa)continue;
		treedp(v,u);
		_min=min(_min,f[v][2]-f[v][0]);
		if(f[v][2]>f[v][0])f[u][0]+=f[v][0];
		else
		{
			k=true;
			f[u][0]+=f[v][2];
		}
		f[u][1]+=f[v][0];
		f[u][2]+=min(f[v][0],min(f[v][1],f[v][2]));
	}
	if(!k)f[u][0]+=_min;
	return;
}
int main()
{
	n=read();
	for(LL i=1;i<=n;++i)
	{
		LL x=read();
		val[x]=read();
		LL m=read();
		while(m--)
		{
			LL y=read();
			addedge(x,y);
			addedge(y,x);
		}
	}
	treedp(1,0);
	printf("%lld\n",min(f[1][0],f[1][2]));
	return 0;
}
